/**
 * This is my code.
 *
 * $Id$
 */
package fi.jab.esb.config.xml.impl;

import fi.jab.esb.config.xml.Listener;
import fi.jab.esb.config.xml.ListenersType;
import fi.jab.esb.config.xml.XmlPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.BasicFeatureMap;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Listeners Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fi.jab.esb.config.xml.impl.ListenersTypeImpl#getListenerGroup <em>Listener Group</em>}</li>
 *   <li>{@link fi.jab.esb.config.xml.impl.ListenersTypeImpl#getListener <em>Listener</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ListenersTypeImpl extends EObjectImpl implements ListenersType
{
  /**
   * The cached value of the '{@link #getListenerGroup() <em>Listener Group</em>}' attribute list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getListenerGroup()
   * @generated
   * @ordered
   */
  protected FeatureMap listenerGroup;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ListenersTypeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return XmlPackage.Literals.LISTENERS_TYPE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FeatureMap getListenerGroup()
  {
    if (listenerGroup == null)
    {
      listenerGroup = new BasicFeatureMap(this, XmlPackage.LISTENERS_TYPE__LISTENER_GROUP);
    }
    return listenerGroup;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Listener> getListener()
  {
    return getListenerGroup().list(XmlPackage.Literals.LISTENERS_TYPE__LISTENER);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case XmlPackage.LISTENERS_TYPE__LISTENER_GROUP:
        return ((InternalEList<?>)getListenerGroup()).basicRemove(otherEnd, msgs);
      case XmlPackage.LISTENERS_TYPE__LISTENER:
        return ((InternalEList<?>)getListener()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case XmlPackage.LISTENERS_TYPE__LISTENER_GROUP:
        if (coreType) return getListenerGroup();
        return ((FeatureMap.Internal)getListenerGroup()).getWrapper();
      case XmlPackage.LISTENERS_TYPE__LISTENER:
        return getListener();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case XmlPackage.LISTENERS_TYPE__LISTENER_GROUP:
        ((FeatureMap.Internal)getListenerGroup()).set(newValue);
        return;
      case XmlPackage.LISTENERS_TYPE__LISTENER:
        getListener().clear();
        getListener().addAll((Collection<? extends Listener>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case XmlPackage.LISTENERS_TYPE__LISTENER_GROUP:
        getListenerGroup().clear();
        return;
      case XmlPackage.LISTENERS_TYPE__LISTENER:
        getListener().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case XmlPackage.LISTENERS_TYPE__LISTENER_GROUP:
        return listenerGroup != null && !listenerGroup.isEmpty();
      case XmlPackage.LISTENERS_TYPE__LISTENER:
        return !getListener().isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (listenerGroup: ");
    result.append(listenerGroup);
    result.append(')');
    return result.toString();
  }

} //ListenersTypeImpl
